// IAC and term length effects, by discretion level

clear all
use data/judgeyear.dta

// code term-length-down as a -1 for term-length-up
replace termup10window = 1 if termdown10window
replace termup10 = -1 if termdown10

foreach y in numops numdisc numwords numwords_maj_m numtoc_maj_m poscites_m distcites_m negcites_m outstatecites_m discusscites_m quotecites_m {

gen log`y' = log(1+`y')

// year FE only
eststo: quietly reg log`y' i.year 			nptou10 ptou10* ptonp10* termup10* iac10* adminoffice10* mandretire10* judgesup10* ptog10* ntou10* nptou10window ptou10window ptonp10window ptog10window ntou10window termup10window iac10window mandretire10window judgesup10window adminoffice10window, 		 vce(cluster stateabb)
// state FE and state trend
eststo: quietly areg log`y' i.year i.statefe#c.year 	nptou10 ptou10* ptonp10* termup10* iac10* adminoffice10* mandretire10* judgesup10* ptog10* ntou10* nptou10window ptou10window ptonp10window ptog10window ntou10window termup10window iac10window mandretire10window judgesup10window adminoffice10window, absorb(statefe) vce(cluster stateabb)
// judge FE and state trend
eststo: quietly areg log`y' i.year i.statefe#c.year 	nptou10 ptou10* ptonp10* termup10* iac10* adminoffice10* mandretire10* judgesup10* ptog10* ntou10* nptou10window ptou10window ptonp10window ptog10window ntou10window termup10window iac10window mandretire10window judgesup10window adminoffice10window, absorb(judgefe) vce(cluster stateabb)

}

esttab using tables/iac-term-2-disc.csv, nogaps replace ar2 se drop(_cons *year *window) star(+ 0.10 * 0.05 ** 0.01)
